import request from '@/request'

export function login(account, password) {
  const data = {
    account,
    password
  }
  return request({
    url: '/users/login',
    method: 'post',
    data
  })
}

export function logout(token) {
  return request({
    headers: {'Authorization': token},
    url: '/users/logout',
    method: 'get'
  })
}

export function getUserInfo(token) {
  return request({
    headers: {'Authorization': token},
    url: '/users/currentUser',
    method: 'get'
  })
}

export function register(userForm) {
  return request({
    url: '/users/register',
    method: 'post',
    data:{
      account: userForm.account,
      password: userForm.password,
      nickname: userForm.nickname,
      email: userForm.email,
      mobilePhoneNumber: userForm.mobilePhoneNumber,
      code: userForm.code,
      
      

    }
  })
}

export function update(userForm) {
  return request({
    url: '/users/update',
    method: 'post',
    data:{
      account: userForm.account,
      oldPassword: userForm.oldPassword,
      password: userForm.password,
      nickname: userForm.nickname,
      avatar: userForm.avatar,
      email: userForm.email,
      mobilePhoneNumber: userForm.mobilePhoneNumber,
      code: userForm.code,

    }
  })
}


